package xyz.zhzby.cyzx.oj.controller;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xyz.zhzby.cyzx.oj.dto.response.SubmissionResponse;
import xyz.zhzby.cyzx.oj.service.ISubmissionService;
import xyz.zhzby.cyzx.servicebase.domain.RestResponse;

import java.util.List;

/**
 * @author zby
 * @date 2022/02/09
 */
@RestController
@RequestMapping("/oj/submission")
@ApiModel("试题相关API")
public class SubmissionController {

    @Autowired
    private ISubmissionService submissionService;

    @ApiOperation("根据试题ID获取本人提交记录（不会很多，不用分页）")
    @PostMapping("/list/{problemId}")
    public RestResponse<List<SubmissionResponse>> getSubmissionList(@PathVariable("problemId") Long problemId) {
        return submissionService.getSubmissionList(problemId);
    }

    @ApiOperation("根据提交记录ID查询提交记录详情")
    @GetMapping("/detail/{submissionId}")
    public RestResponse<SubmissionResponse> getSubmissionById(@PathVariable("submissionId") Long submissionId) {
        return submissionService.getSubmissionById(submissionId);
    }

}
